// Copyright (C) joyinter
// All rights reserved.
// 
// Author : Jiang Li
// Date   : 2004-12-6

#ifndef __BASE_TIME_H_COMMON_SVR_BASE__
#define __BASE_TIME_H_COMMON_SVR_BASE__

#pragma once


namespace JoyServer
{

//##ModelId=44CEFAD100AD
class CJoyTimeSpan
{
public:
    //UINT    m_day;
	//##ModelId=44CEFAD100AE
    UINT    m_hour;
	//##ModelId=44CEFAD100AF
    UINT    m_minute;
	//##ModelId=44CEFAD100BB
    UINT    m_second;
	//##ModelId=44CEFAD100BC
    UINT    m_milli;
};

void JoyGetTimeSpan(CJoyTimeSpan& span, UINT64 millisecond);
void JoyGetTimeSpan(CJoyTimeSpan& span, const FILETIME& start, const FILETIME& end);
void JoyGetTimeSpan(CJoyTimeSpan& span, const SYSTEMTIME& start, const SYSTEMTIME& end);
void JoyGetCurrentFileTime(FILETIME& curr);
void JoyGetProcessTimes(UINT64& kernelTime, UINT64& userTime);
UINT64 JoyGetCurrentTick();

// return difference as millisecond.
inline UINT64 JoyGetTimeDiff(const FILETIME& start, const FILETIME& end)
{
    UINT64 diff = (*(UINT64*)&end / 10000) - (*(UINT64*)&start / 10000);
    return diff;
}

} // namespace JoyServer

#endif  // __BASE_TIME_H_COMMON_SVR_BASE__
